package com.eqdd.yiqidian.ui.yiqiyue;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.support.v4.app.Fragment;
import android.view.View;

import com.eqdd.yiqidian.R;
import com.eqdd.yiqidian.YueMainActivityCustom;
import com.eqdd.yiqidian.adapter.MyFragmentPagerAdapter;
import com.eqdd.yiqidian.base.BaseActivity;
import com.eqdd.yiqidian.ui.yiqiyue.fragment.YueFragment;
import com.eqdd.yiqidian.ui.yiqiyue.fragment.YueHomeFragment;
import com.eqdd.yiqidian.ui.yiqiyue.fragment.YueMineFragment;
import com.eqdd.yiqidian.utils.ClickUtil;
import com.eqdd.yiqidian.utils.PicUtil;
import com.jakewharton.rxbinding.view.RxView;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.entity.LocalMedia;
import com.roughike.bottombar.BottomBarTab;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;

import cn.jiguang.share.android.api.JShareInterface;
import cn.jiguang.share.android.api.PlatActionListener;
import cn.jiguang.share.android.api.Platform;
import cn.jiguang.share.android.api.ShareParams;
import cn.jiguang.share.qqmodel.QQ;

/**
 * @author吕志豪 .
 * @date 17-12-6  下午2:22.
 * Github :https://github.com/lvzhihao100
 * E-Mail：1030753080@qq.com
 * 简书 :http://www.jianshu.com/u/6e525b929aac
 */

public class YueMainActivity extends BaseActivity {

    private YueMainActivityCustom dataBinding;
    private BottomBarTab yue0;
    private BottomBarTab yue1;
    private BottomBarTab yue2;

    @Override
    public void initBinding() {
        dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_yiqiyue);
        initTopTitleBar(View.VISIBLE, "易企阅");
        initTopRightText("添加", v -> {
            startActivity(AddArticleActivity.class);
        });
        dataBinding.includeTitle.ivSearch.setVisibility(View.VISIBLE);
        ClickUtil.click(dataBinding.includeTitle.ivSearch, () -> {


        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

    }

    @Override
    public void initData() {
        ArrayList<String> title = new ArrayList<>();
        title.add("0");
        title.add("1");
        title.add("2");
        ArrayList<Fragment> fragments = new ArrayList<>();
        fragments.add(new YueHomeFragment());
        fragments.add(new YueHomeFragment());
        fragments.add(new YueMineFragment());
        dataBinding.viewPager.setAdapter(new MyFragmentPagerAdapter(getSupportFragmentManager(), title, fragments));
    }

    @Override
    public void setView() {
        yue0 = dataBinding.bottomBar.getTabWithId(R.id.tab_yue_0);
        yue1 = dataBinding.bottomBar.getTabWithId(R.id.tab_yue_1);
        yue2 = dataBinding.bottomBar.getTabWithId(R.id.tab_yue_2);
        dataBinding.bottomBar.setDefaultTab(R.id.tab_yue_0);
        dataBinding.bottomBar.setOnTabSelectListener(this::onChecked);
    }

    private void onChecked(int tabId) {
        switch (tabId) {
            case R.id.tab_yue_0:
                dataBinding.viewPager.setCurrentItem(0);
                break;
            case R.id.tab_yue_1:
                dataBinding.viewPager.setCurrentItem(1);
                break;
            case R.id.tab_yue_2:
                dataBinding.viewPager.setCurrentItem(2);
                break;
        }
    }
}
